package com.xiran.mointer.controller;




import com.xiran.mointer.model.SystemMetrics;
import com.xiran.mointer.service.SystemMonitorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class MonitorController {

    @Autowired
    private SystemMonitorService monitorService;

    // 返回监控页面
    @GetMapping("/monitor")
    public String monitorPage() {
        return "monitor"; // 对应 templates/monitor.html
    }

    // 提供实时数据接口
    @GetMapping("/api/metrics")
    @ResponseBody
    public SystemMetrics getMetrics() {
        return monitorService.getSystemMetrics();
    }
}